﻿using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using POS.DataObjects;
using POS.BusinessEntities;

namespace POS.DataObjectsTest
{
    [TestClass]
    public class DOUbicacionTest
    {
        #region Declarations

        private static Database db;
        //private const string TestUser = "testUser";
        private const int EmpresaId = 1;

        #endregion
        
        #region Properties: Non-Public

        private static Database Db
        {
            get
            {
                if (db == null)
                    db = DatabaseFactory.CreateDatabase();
                return db;
            }
        }

        #endregion

        [TestMethod]
        public void GetPaisList()
        {
            var entityType = TipoEntidad.Pais;
            var ds = Db.ExecuteDataSet(CommandType.Text, "select * from pais");
            var filtro = "";
            var results = new DOEntidad(entityType).GetList(EmpresaId, filtro);
            DOEntidadTest.AssertGetListResult(ds, results, entityType);
        }

        [TestMethod]
        public void GetProvinciaListByPaisId()
        {
            var paisId = 1; // it assumes there's a country with that Id
            var entityType = TipoEntidad.Provincia;
            var ds = Db.ExecuteDataSet(CommandType.Text, "select * from provincia where paisId = " + paisId);
            //var filtro = "";
            var results = new DOUbicacion().GetProvinciaList(paisId);
            DOEntidadTest.AssertGetListResult(ds, results, entityType);
        }

    }
}
